/**
 * Created by 小敏哥 on 2017/7/13.
 */
import React, {Component} from 'react';
import style from './index.scss';
import AlipayJSOperation from '../../utils/alipayJSOperation';
import common from '../../utils/common';
import urlOperation from '../../utils/urlOperation';
import ProcessDetails from './processDetails';
import SendCxytjMessage from '../../utils/sendCxytjMessage';
import appVersion from "../../utils/appVersion";
import jsApi from "../../utils/cx580.jsApi";
class RemindProcessDetail extends Component {
    constructor(props) {
        super(props);
    }

    toUrl(url) {
        SendCxytjMessage.sendMessage({
            eventId: 'H5_E_Interspection_ClickGetit', //事件标记
            productId: 'allInspectionReminder',
            attr1: this.props.params.inspectionType //属性1
        });
        if (navigator.userAgent.indexOf("appname_cxycwz") > -1) {
            //此处增加app用于识别年检提醒
            let finalUrl = `${urlOperation.urlInformation.fullPathname}?detailUserType=app#${url}`;
            if(appVersion.getMainVersionByCount()>=6.33){
                finalUrl = `${urlOperation.urlInformation.fullPathname}?detailUserType=app&api_version=3#${url}`;
            }
            common.openNewBrowserWithURL(finalUrl);
        }
        else {
            this.context.router.push(url);
        }
    }

    /* setActiveTab(){
     this.refs.reTab.setActive(this.props.params.inspectionType-1);
     }*/

    componentDidMount() {
        //首页隐藏标题栏右键
        AlipayJSOperation.setRightButtonStatus(false);
        AlipayJSOperation.setTitle('办理年检');
        document.querySelector("title").innerHTML = "办理年检";
        // this.setActiveTab();


        if (navigator.userAgent.indexOf("appname_cxycwz") > -1) {
            //隐藏右侧功能按钮
            setTimeout(() => {
                jsApi.call({
                    "commandId":"",
                    "command":"customizeTopRightButton",
                    "data":{
                        "list":[]}
                },function(data){})
            }, 200)
        }

        SendCxytjMessage.sendMessage({
            eventId: this.props.params.inspectionType=='1'?'H5_P_Interspection_EnterDescriptionpage1':'H5_P_Interspection_EnterDescriptionpage2',
            productId: 'allInspectionReminder',
        });
    }


    render() {
        let {url,inspectionType} = this.props.params;
        // url = decodeURIComponent(url);
        return <div className={style.remindDetailContainer}>
            <ProcessDetails inspectionType={this.props.params.inspectionType}/>
            <div style={{height: '1.64rem', width: '100%'}}></div>
            <div className={style.footerBtn}>
                <button className={style.btn} onClick={() => this.toUrl(url+'/'+inspectionType)}>我已知晓</button>
            </div>
        </div>
    }
}

//使用context
RemindProcessDetail.contextTypes = {
    router: React.PropTypes.object.isRequired
};


export default RemindProcessDetail